<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8" />
    <!-- 引入刚刚下载的 ECharts 文件 -->
    <script src="echarts.js"></script>
    <script src="axios.js"></script>
</head>

<body>
<div>
    <div id="main" style="width: 1000px;height:800px"></div>
    <script type="text/javascript">
        // 基于准备好的dom，初始化echarts实例
        var myChart = echarts.init(document.getElementById('main'));
        // 指定图表的配置项
        var option = {
            title: {
                text: '会员注册数量统计'
            },
            tooltip: {},
            legend: {
                data: ['会员数量']
            },
            xAxis: {
                data: []
            },
            yAxis: {
                type: 'value'
            },
            series: [{
                name: '会员数量',
                type: 'line',
                smooth: true,
                label: {
                    show: true
                },
                data: []
            }]
        }
        // 使用刚指定的配置项
        myChart.setOption(option);
        // let response = {
        //     code: 200,
        //     msg: "获取成功",
        //     data: {
        //         months: ['2022-1', '2022-2', '2022-3', '2022-4'],
        //         count: ["5", "10", "6", "12"]
        //     }
        // }
        //获取图片数据
        axios.get("/report/member").then(resp => {
            const data = resp.data.data;
            //使用获取的数据
            myChart.setOption({
                xAxis: {
                    data: data.months
                },
                series: [{
                    data: data.months,
                    data: data.count
                }]
            });
        });
    </script>
</div>
</body>

</html>
